home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 3 / ct-rom iiib.zip / ct-rom iiib / WINDOWS / UTILITY / DESKTOP / W_ONE49 / MERGE.CP_ / MERGE.CP
Text File  |  1994-04-27  |  3KB  |  85 lines

  1. /******************************************************************\
  2. *                                                                  *
  3. *          w       w                oooo                           *
  4. *          w       w  iii  n   n   o    o   n   n  eeee            *
  5. *          w       w   i   nn  n  o      o  nn  n  e               *
  6. *          w   w   w   i   n n n  o      o  n n n  eee             *
  7. *           w w w w    i   n  nn   o    o   n  nn  e               *
  8. *            w   w    iii  n   n    oooo    n   n  eeee            *
  9. *                                                                  *
  10. *     C o m m a n d   L a n g u a g e   I n t e r p r e t e r      *
  11. *                                                                  *
  12. *                                                                  *
  13. *   External Command MERGE                                         *
  14. *   Written by Lucien Cinc                                         *
  15. *   Copyright (c) 1993                                             *
  16. *                                                                  *
  17. \******************************************************************/
  18.  
  19. #include "merge.h"
  20.  
  21. int merge(void);    // proto type
  22.  
  23. int main(void)
  24. {
  25.     char *sp;
  26.  
  27.     sp = args();                // parse command line switches
  28.     while(*sp)
  29.         switch(*sp++) {
  30.             case 'v' :          // show version information
  31.                        printf("%cVersion %c%d.%01d\n", WHITE, YELLOW, VERSION / 10, VERSION % 10);
  32.                        return 0;
  33.             default:            // invalid switch
  34.                        perror("Invalid switch");
  35.                        return 1;
  36.         }
  37.  
  38.     if (argnstr()) {            // no command line string arguments
  39.         perror("Invalid argument");
  40.         return 1;
  41.     }
  42.  
  43.     if (argc() != 3) {            // no command line arguments
  44.         perror("To many or few arguments");
  45.         return 1;
  46.     }
  47.  
  48.     return merge();
  49. }
  50.  
  51. int merge(void)
  52. {
  53.     long num1, num2;
  54.     char dst[MAXPATH], src1[MAXPATH], src2[MAXPATH];
  55.  
  56.     strcpy(dst, argpath(3));     // destination file
  57.     strcpy(src1, argpath(1));    // first file
  58.     strcpy(src2, argpath(2));    // second file
  59.  
  60.     if ((num1 = filesize(src1)) == -1) {        // get first file size
  61.         perror("Invalid path or file name");
  62.         return 1;
  63.     }
  64.  
  65.     if ((num2 = filesize(src2)) == -1) {        // get second file size
  66.         perror("Invalid path or file name");
  67.         return 1;
  68.     }
  69.  
  70.     limit(num1 + num2);    // status bar limit
  71.  
  72.     if (filecpy(dst, src1, O_CREATNEW, INC_BYTE) == -1) {
  73.         empty();
  74.         return 1;
  75.     }
  76.  
  77.     if (filecat(dst, src2, INC_BYTE) == -1) {
  78.         empty();
  79.         return 1;
  80.     }
  81.  
  82.     empty();        // finished with status bar
  83.  
  84.     return 0;
  85. }